package com.authine.cloudpivot.engine.plugin.service.impl;

import com.alibaba.dubbo.common.utils.CollectionUtils;
import com.authine.cloudpivot.engine.plugin.domain.OpenFormType;
import com.authine.cloudpivot.engine.plugin.repository.OpenFormTypeRepository;
import com.authine.cloudpivot.engine.plugin.service.OpenFormTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

@Service
@Transactional
public class OpenFormTypeServiceImpl   implements OpenFormTypeService {


    @Autowired
    OpenFormTypeRepository  openFormTypeRepository;



    @Override
    public OpenFormType findOpenFormTypeBysSchemaCodeAndCode(String scheamCode, String code) {
        List<OpenFormType> list = openFormTypeRepository.findOpenFormTypesBySchemaCodeAndCode(scheamCode,code);

        return  CollectionUtils.isNotEmpty(list) ?  list.get(0) : null;
    }

    @Override
    public void saveOpenFormType(OpenFormType openFormType) {
        openFormTypeRepository.save(openFormType);
    }

}
